package com.heima.comment.controller;


import com.heima.comment.service.ApCommentRepayService;
import com.heima.comment.service.ApCommentService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentRepayLikeDto;
import com.heima.model.comment.pojos.ApComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {


    @Autowired
    private ApCommentService apCommentService;





    /**
     * 保存评论
     * @param commentDto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentDto commentDto){
       return apCommentService.saveComment(commentDto);
    }

    /**
     * 查询评论列表
     * @param commentDto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult<List<ApComment>> load(@RequestBody CommentDto commentDto){
       return apCommentService.load(commentDto);
    }

    /**
     * 评论点赞 取消
     * @param dto
     * @return
     */
    @PostMapping("like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return apCommentService.like(dto);
    }
}
